package com.zz.service.iml;

import com.zz.dao.WardDao;
import com.zz.dto.AreaOccupancyRate;
import com.zz.dto.OccupancyRate;
import com.zz.pojo.Ward;
import com.zz.service.WardService;
import com.zz.utils.WardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Copyright Zz
 * FileName: WardServiceIml
 * Author:   Zz
 * Date:     2023/6/1113:59
 * Description:房间表业务层实现类
 * hISTORY:
 * <author>  <time>     <version>    <desc>
 * 作者姓名   修改时间       版本号       描述
 */
@Service
@Transactional
public class WardServiceIml implements WardService {
    @Autowired
    private WardDao wardDao;

    @Override
    public OccupancyRate getOccupancyRate() {
        List<Ward> wardList=wardDao.queryOccupancyInformation();
        return WardUtil.calculateOccupancyRate(wardList);
    }

    @Override
    public List<Ward> getOccupancyInformation(String areaCode) {
        return wardDao.queryOccupancyInformationByAreaCode(areaCode);
    }
}
